<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>营销管理</title>
    <meta name="keywords" content="">
    <meta name="description" content="">
    <link rel="shortcut icon" href="__PUBLIC__/admin/favicon.ico">
    <link href="__PUBLIC__/admin/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="__PUBLIC__/admin/css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
    <link href="__PUBLIC__/admin/css/animate.css" rel="stylesheet">
    <link href="__PUBLIC__/admin/css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="__PUBLIC__/admin/css/style.css?v=4.1.0" rel="stylesheet">
    <link href="__PUBLIC__/admin/js/plugins/fancybox/jquery.fancybox.css" rel="stylesheet">
</head>
<include file="Admin@Index:cache" />
<body class="gray-bg contacts">
<style>
    .table-hover>tbody>tr>td{
        height:4rem;
    }
</style>
<div class="wrapper wrapper-content animated fadeInRight" oncopy="copyval()">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox">
                <div class="ibox-title">
                    <h5>营销管理</h5>
                </div>
                <div class="ibox-content">
                    <div class="col-sm-12" style="margin-bottom: 1rem">
                        <form role="form" action="__SELF__" method="get">
                            <div class="form-group">
                                <input type="text" id="content" placeholder="" name="content" class="form-control">
                            </div>
                            <div>
                                <select name="state" id="state" class="form-control m-b"  style="margin-bottom: 0;padding-top: 3px;display: inline;width: 10%;" >
                                    <option value="">状态</option>
                                    <option value="0" <if condition="$_GET['state'] heq '0'">selected</if>>未跟进</option>
                                    <option value="1" <if condition="$_GET['state'] heq '1'">selected</if>>洽谈中</option>
                                    <option value="2" <if condition="$_GET['state'] heq '2'">selected</if>>未接通</option>
                                    <option value="3" <if condition="$_GET['state'] heq '3'">selected</if>>无意向</option>
                                    <option value="4" <if condition="$_GET['state'] heq '4'">selected</if>>已成交</option>
                                </select>
                                <button class="btn btn-sm btn-primary pull-right m-t-n-xs" type="submit" id="search"><strong>搜索</strong></button>
                            </div>
                        </form>
                    </div>
                    <br>
                    <table class="table table-hover table-mail">
                        <tbody id="list">
                        <tr>
                            <th  width="80px">
                                <input type="checkbox" id="all"> 序号
                            </th>
                            <th>姓名</th>
                            <th>手机号</th>
                            <th>手机型号</th>
                            <th>创建时间</th>
                            <th width="240px">备注</th>
                            <th>标识</th>
                            <th class="client-status" width="320px">操作</th>
                        </tr>
                        <foreach name="list" item="list">
                            <tr>
                                <td><input type="checkbox"  value="<{$list.id}>" name="check"></td>
                                <td><{$list.name}></td>
                                <td><{$list.mobile}></td>
                                <td><{$list.phone}></td>
                                <td><{$list.ctime}></td>
                                <td><{$list.remarks}></td>
                                <td>
                                    <switch name="list.state">
                                        <case value="0">未跟进</case>
                                        <case value="1">洽谈中</case>
                                        <case value="2">未接通</case>
                                        <case value="3">无意向</case>
                                        <case value="4">已成交</case>
                                    </switch>
                                </td>

                                <td class="client-status">
                                    <a class="btn btn-info btn-rounded " href="javascript:;" onclick="apply('<{$list.id}>','<{$list.remarks}>','<{$list.list.state}>')">编辑</a>
                                    <a class="btn btn-danger btn-rounded" rid="<{$list.id}>" href="javascript:;" onclick="batch('<{$list.id}>');" >删除</a>
                                </td>
                            </tr>
                        </foreach>
                        </tbody>
                        <tfoot>
                        <tr>
                            <td colspan="8">
                                <input name="" class="btn btn-danger" id="batch" type="button" value="批量删除"  onclick="batch(0)"/>
                            </td>
                        </tr>
                        </tfoot>
                    </table>
                    <ul class="pagination">
                        <if condition="$tol gt 10">
                            <{$fpage}>
                        </if>
                    </ul>
                </div>
            </div>
        </div>
    </div>
</div>

<!-- 全局js -->
<script src="__PUBLIC__/admin/js/jquery.min.js?v=2.1.4"></script>
<script src="__PUBLIC__/admin/js/bootstrap.min.js?v=3.3.6"></script>
<script src="__PUBLIC__/admin/js/layer/layer.js"></script>
<script src="__PUBLIC__/admin/js/layui/layui.js"></script>
<!-- 自定义js -->
<script src="__PUBLIC__/admin/js/content.js?v=1.0.0"></script>
<script src="__PUBLIC__/admin/js/plugins/fancybox/jquery.fancybox.js"></script>
<script>
    var op=1;
    var picop=1;
    function batch(id) {
        if(op==2){
            layer.close(index);
            layer.msg('请勿重复点击',{icon:5,time:2000});
            return false;
        }
        op=2;
        var index = layer.load(1, {
            shade: [0.1,'#fff'] //0.1透明度的白色背景
        });
        var text='';
        var vals='';
        if(id==0){
            text='确认要批量删除选中数据吗？'
            var valArr = new Array;
            $("#list input[name=check]").each(function(i){
                valArr[i] = $(this).val();
            });
            vals = valArr.join(',');
            if(vals==''){
                layer.close(index);
                layer.msg('请选择要删除的数据!', {icon: 5, time: 1000});
                op=1;
                return false;
            }
        }else{
            text='确认要删除选中数据吗？'
            vals=id;
        }

        layer.confirm(text, {
            btn: ['确定','取消'] //按钮
        }, function (index) {
            $.post("__MODULE__/Operate/delmarket", {
                    id: vals,
                },
                function (data) {
                    op=1;
                    layer.closeAll();
                    if(data.code=='1001'){
                        window.location.reload();
                    }else{
                        if(data.status=='0'){
                            layer.msg(data.info,{time:2000,icon:5});
                        }else{
                            layer.msg(data.result,{time:2000,icon:5});
                        }
                    }
        });
    }, function(){
            op=1;
            layer.close(index);
        });
    }




    $(function () {
        //全选或全不选
        $("#all").click(function(){
            if(this.checked){
                $("#list :checkbox").prop("checked", true);
            }else{
                $("#list :checkbox").prop("checked", false);
            }
        });
    //设置全选复选框
    $("#list :checkbox").click(function(){
        allchk();
    });

    //获取选中选项的值
    $("#getValue").click(function(){
        var valArr = new Array;
        $("#list input[name=check]").each(function(i){
            valArr[i] = $(this).val();
        });
        var vals = valArr.join(',');
    });
    });
    function allchk(){
        var chknum = $("#list :checkbox").size();//选项总个数
        var chk = 0;
        $("#list :checkbox").each(function () {
            if($(this).prop("checked")==true){
                chk++;
            }
        });
        if(chknum==chk){//全选
            $("#all").prop("checked",true);
        }else{//不全选
            $("#all").prop("checked",false);
        }
    }




    $(document).ready(function () {
        $('.contact-box').each(function () {
            animationHover(this, 'pulse');
        });
    });
    $(document).ready(function () {
        $('.fancybox').fancybox({
            openEffect: 'none',
            closeEffect: 'none'
        });
    });

    function apply(id,remarks,state){
        var str='selected';
        var html='';
        html+='<div class="modal-body" id="lists" style="height:100%">';
        html+='<form class="form-horizontal">';
        html+='<div class="form-group">';
        html+='<label class="col-sm-3 control-label" >备注：</label>';
        html+='<div class="col-sm-8">';
        html+='<textarea style="height:10rem" type="text" id="remarks" placeholder="" class="form-control" >'+remarks+'</textarea>';
        html+='</div>';
        html+='</div>';
        html+='<div class="form-group">';
        html+='<label class="col-sm-3 control-label">选择标识：</label>';
        html+='<div class="col-sm-8">';
        html+='<select class="form-control m-b" name="state1" id="state1" style="height:3rem">';
        html+='<option value="0" ';
        if(state==0){
            html+= str;
        }
        html+='>未跟进</option>>';
        html+='<option value="1" ';
        if(state==1){
            html+= str;
        }
        html+='>洽谈中</option>>';

        html+='<option value="2" ';
        if(state==2){
            html+= str;
        }
        html+='>未接通</option>>';
        html+='<option value="3" ';
        if(state==3){
            html+= str;
        }
        html+='>无意向</option>>';
        html+='<option value="4" ';
        if(state==4){
            html+= str;
        }
        html+='>已成交</option>>';
        html+='</select>';
        html+='</div>';
        html+='</div>';
        html+='</form>';
        html+='<div class="modal-footer" style="border:0">';
        html+='<a href="javascript:void(0);" onclick="layer.closeAll()" type="button" class="btn btn-default" >关闭</a>';
        html+='<a href="javascript:void(0);" onclick="applys(\''+id+'\',1);" type="button" class="btn btn-primary" >修改</a>';
        html+='</div>';
        html+='</div>';

        layer.open({
            type: 1, //Page层类型
            area: ['530px', '450px'],
            title: '编辑',
            shade: 0.6, //遮罩透明度
            maxmin: true, //允许全屏最小化
            anim: 1, //0-6的动画形式，-1不开启
            content: html
        });
    }

    function applys(id){
        if(op==2){
            layer.close(index);
            layer.msg('请勿重复点击',{icon:5,time:2000});
            return false;
        }
        op=2;
        var remarks=$('#remarks').val();
        var state=$("#state1 option:selected").val();
        if(state==""){
            op=1;
            layer.msg('请选择标识',{icon:5,time:2000});
            return false;
        }
        layer.confirm('确定要编辑渠道数据吗？',function(){
            $.post('__MODULE__/Operate/market_edit',{id:id,remarks:remarks,state:state},function(data){
                op=1;
                if(data.code=='1001'){
                    window.location.reload();
                }else{
                    if(data.status=='0'){
                        layer.msg(data.info,{time:2000,icon:5});
                    }else{
                        layer.msg(data.result,{time:2000,icon:5});
                    }
                }
            });
        });
    }

    //删除
    function del(id){
        if(op==2){
            layer.close(index);
            layer.msg('请勿重复点击',{icon:5,time:2000});
            return false;
        }
        op=2;
        layer.confirm('是否确定删除该数据',function(){
            $.post('__MODULE__/Operate/delmarket',{id:id},function(data){
                op=1;
                if(data.code=='1001'){
                    window.location.reload();
                }else{
                    if(data.status=='0'){
                        layer.msg(data.info,{time:2000,icon:5});
                    }else{
                        layer.msg(data.result,{time:2000,icon:5});
                    }
                }
            });
        });
    }


    function copyval() {
        var content = window.getSelection().toString();
        $.post('__MODULE__/Mypublic/copy_all', {content:content}, function (data) {
            if (data.code == '1001') {
            } else {
                console.log(data);
            }
        });
    }
</script>


</body>

</html>
